#include "Base\Engine.h"
#include "Base\Surface.h"
#include "UI\Widgets\WidgetFactory.h"
#include "UI\Controls\SimpleControl.h"

///////////////////////////////////////////////////////////
//        ///  //////  /        ///  ///////  ///        //
//  //////  /  //////  /  //////  /  ///////  /  //////////
//        ///  //////  /        ///  ///////  /  //////////
//  /////////  //////  /  //////  /  ///////  /  //////////
//  ///////////      ///        ///        /  ///        //
///////////////////////////////////////////////////////////

bool ShRp::UI::Controls::SimpleControl::Init( int2 _Pos, int2 _Size )
{
	if(!Control::Init(_Pos, _Size))
		return false;

	Widgets::Button* button = (Widgets::Button*)WidgetFactory::CreateWidget(Widget::Type::Button, this);
	button->Init(int2(0, 0), int2(50, 20), "ButtonTest");
	return true;
}

////////////////////////////////////////////////////////////////
//      ///      ///  /  //////  ///    ///          /        //
//  ////  /  ////  /  /  //////  /  ////  /////  /////  ////////
//      ///      ///  ///  //  ///        /////  /////      ////
//  ///////  //  ///  ///  //  ///  ////  /////  /////  ////////
//  ///////  ////  /  /////  /////  ////  /////  /////        //
////////////////////////////////////////////////////////////////

ShRp::UI::Controls::SimpleControl::SimpleControl()
	: Control(Control::Type::SimpleControl)
{
	
}

void ShRp::UI::Controls::SimpleControl::Paint()
{
	Base::Surface::StartPaint(this);
	//  ////////////////////////////////////||\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	//  ||							   Render Area.								||
	//  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\||////////////////////////////////////

	for(WidgetVector::iterator widgetIt = m_Children.begin(); widgetIt != m_Children.end(); ++widgetIt)
	{
		(*widgetIt)->Paint();
	}
	
	//  ////////////////////////////////////||\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	//  ||							End of Render Area.							||
	//  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\||////////////////////////////////////
	Base::Surface::EndPaint(this);
}

void ShRp::UI::Controls::SimpleControl::MouseDown( MouseButton::E _Btn )
{
	Control::MouseDown(_Btn);
}

void ShRp::UI::Controls::SimpleControl::MouseUp( MouseButton::E _Btn )
{
	Control::MouseUp(_Btn);
}

void ShRp::UI::Controls::SimpleControl::KeyDown( Key::En _Key )
{
	Control::KeyDown(_Key);
}

void ShRp::UI::Controls::SimpleControl::KeyRepeat( Key::En _Key )
{
	Control::KeyRepeat(_Key);
}

void ShRp::UI::Controls::SimpleControl::KeyUp( Key::En _Key )
{
	Control::KeyUp(_Key);
}